package com.san.hkhospital.controller;
import com.github.pagehelper.PageInfo;
import com.san.hkhospital.entity.Apparatus;
import com.san.hkhospital.entity.ApparatusExample;
import com.san.hkhospital.service.ApparatusService;
import com.san.hkhospital.service.impl.ApparatusServiceImpl;
import com.san.hkhospital.vo.ApparatusTableVo;
import com.san.hkhospital.vo.ResultVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
* (apparatus)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/apparatus")
public class ApparatusController {
/**
* 服务对象
*/
@Resource
private ApparatusServiceImpl apparatusServiceImpl;
@Resource
private ApparatusService apparatusService;


@RequestMapping("selectApparatus")
    public ResultVO selectApparatus(@RequestParam Integer sectionId,@RequestParam Integer stateId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){
    PageInfo apparatusTableVos = apparatusService.selectAll(sectionId, stateId,pageNum,pageSize);
    return ResultVO.success("仪器查询成功！",apparatusTableVos);
}
@PostMapping
    public ResultVO addApparatus(@RequestBody Apparatus apparatus){
    boolean b = apparatusService.addApparatus(apparatus);
    if (b){
        return ResultVO.success("仪器添加成功！");
    }
    return ResultVO.failed("仪器添加失败！");
}
@PostMapping("/updateApparatus")
    public ResultVO updateApparatus(@RequestBody Apparatus apparatus){
    int i = apparatusService.updateApparatus(apparatus);
    if (i==0){
        return ResultVO.failed("仪器修改失败！");
    }
    return ResultVO.success("仪器修改成功！");
}
}
